package org.example.cloudapply.repository;

import org.apache.ibatis.annotations.*;
import org.example.cloudapply.entity.User;

@Mapper
public interface UserRepository {
    @Select("SELECT * FROM users WHERE openid = #{openid}")
    User findByOpenid(String openid);

    @Insert("INSERT INTO users (openid) VALUES (#{openid})")
    @Options(useGeneratedKeys = true, keyProperty = "userId")
    int insert(User user);

    @Update("UPDATE users SET openid=#{openid} WHERE user_id=#{userId}")
    int update(User user);

    @Select("SELECT * FROM users WHERE user_id = #{userId}")
    User findByUserId(Integer userId);
}